<?PHP
/**
 *          This is the page registered users use to view
 *          all of their upcoming reservations.
 *
 * @version 0.1
 *          Version History:
 *          0.1  Surabhi created
 */

?>
<?PHP
/* LOGIN SEQUENCE
 * This php code must be included at the top of every page
 *
 */
session_start();
require('../basicInfo/user.php');
require('question.php');
require('course.php');
$_SESSION['currentPage'] = "questionbank";
if(isset($_SESSION['userinfo'])) {
    /* user is logged in
     * retreive the user object created when checked
     */
  //  $_SESSION['currentPage'] = 'addquestion';
$userinfo=unserialize($_SESSION['userinfo']);
} else {
  header("Location:signin.php");
}

?>
<?php
$courseArr = CourseController::getCourseList();
//echo "first value: ".$courseArr[0];
//echo "first value: ".$courseArr[1];

//if(isset($_GET['course'])){ if(isset($_GET['level'])){
  //      $course=$_GET['course'];
    //    $level=$_GET['level'];
  //$courseTopicsArr = CourseController::getTopics();

//}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Debugger MMO</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-US" />
<style type="text/css"><!--
    #profile
    {
            float: left;
            width: 200px;
            height:400px;
            border: 1px solid #639684;
            margin: 8px 8px 8px 8px;
            background-color:#87CEEB;
    }

    #question_creator1
    {
        float:left;
        width:490px;
        height: 500px;
        border:1px solid #639684;
        border-top-style:4px solid #D2B48C;
        margin-top:8px;
        margin-bottom:8px;
        margin-left:2px;
        margin-right:8px;
        background-color: #FFEFD5;

    }
    #question_creator
    {
       float: left;
	   margin: 8px 4px;
      width:490px;
       background-color: #FFEFD5;
       border: 3px solid #d5c8a4;
    }

    #clear_button
    {
        background-color:#F4A460;
        float:left;
        margin-left: 100px;
        margin-top:20px;
        width:100px;
    }

    #submit_button
    {
        background-color:#F4A460;
        float: right;
        margin-right: 200px;
        margin-top:20px;
        width:100px;
    }

    #creator_heading
    {
        width:490px;
        height:15px;
        margin-top:0px;
        background-color:#BC8F8F;
        font-family:Verdana;
        text-align:left;
        color: white;
        font-size:10px;
    }

    #drop_downs
    {
        border:none;
        margin-top:20px;
        margin-left:5px;
        margin-right:5px;
        background-color: #FFEFD5;
    }
    #drop_downs select
    {
        width: 110px;
        height:20px;
        border: 1px solid #BC8F8F;

    }

    #write_question
    {
        border: none;
        margin-top:20px;
        margin-left:5px;
        margin-right:5px;
        background-color:#FFEFD5;


    }

    #write_question input
    {
      border: 1px solid #BC8F8F;
      margin-left:10px;
      
    }

    #write_question select
    {
      border: 1px solid #BC8F8F;
     

    }
    #write_question textarea
    {
        margin-left:10px;
        border: 1px solid #BC8F8F;
    }

    #choices
    {
       border: none;
        margin-top:20px;
        margin-left:5px;
        margin-right:5px;
        background-color:#FFEFD5;
    }

    #choices input
    {
       border: 1px solid #BC8F8F;
       margin-left:10px;

    }

  #topicsDiv
  {
      float: right;
      margin-right: 100px;
      width: 150 px;
      height: 20 px;
  }

  #goldDiv
  {
      float: right;
      margin-right: 100px;
      margin-top: 94px;
  }

  #goldDiv input
  {
      border: 1px solid #BC8F8F;
      margin-left:10px;
  }


    --></style>

<script type="text/javascript">
 function onLevelSelect(selectedCourse, selectedLevel){
     //alert("course and level are" + selectedCourse + "and" + selectedLevel);
     if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("topicsDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","includes/addquestiontopic.php?course="+selectedCourse+"&level="+selectedLevel,true);
xmlhttp.send();
     
 }

 function fnOnchangeCombo()
 {

     alert("I got changed");
 }

 function formreset(){
     form1.reset();
 }

 function isValid(){
     if(document.form1.course.value=="Select Course" || document.form1.course.value==""){
         alert("No Course Selected!!");
         return false;
     }

     if(document.form1.level.value=="Select Level" || document.form1.level.value==""){
         alert("No Level Selected!!");
         return false;
     }


     if(document.form1.title.value=="Write title of your question" || document.form1.title.value==""){
         alert("Write a title!!");
         return false;
     }

     if(document.form1.time.value=="Time in sec" || document.form1.time.value==""){
         alert("Specify time!!");
         return false;
     }


     if(document.form1.question.value=="Write your question here" || document.form1.question.value==""){
         alert("Write the question!!");
         return false;
     }

     if(document.form1.first.value==""){
         alert("First give Choice1!!");
         return false;
     }

     if(document.form1.second.value==""){
         alert("Give Choice2!!");
         return false;
     }

     if(document.form1.correct_answer.value=="OFF"){
         alert("Specify the correct answer!!");
         return false;
     }

 }
</script>

</head>
    <body>
<?php include "../../layout/header.php"; ?>
<?php include "../../layout/navleft.php"; ?>
<div id="question_creator">
        <form name="form1" method="POST" action="addquestionconfirm.php" onsubmit="return isValid()">
        
                    <div id="creator_heading">Create Question </div>
                    <div id="drop_downs">
                        
                       Course: <select name="course">
                           <option>Select Course </option>
                     <?php  for($i=0; $i< sizeof($courseArr); $i++){ ?>
                        <option> <?php //echo $courseArr[$i]->getCId() .": Section-". $courseArr[$i]->getSection();
                                         echo $courseArr[$i]->getCId()."-".$courseArr[$i]->getSection();?></option>
                         <?php } ?>
                        </select>
                       Level:  <select name="level"  onchange="onLevelSelect(course.value, this.value)">
                           <option>Select Level </option>
                          <option> Easy </option>
                            <option> Medium</option>
                            <option> Tough</option>
                            
                        </select>
                     
                          <?php if(!isset($_GET['course'])&& !isset($_GET['level'])){?>

                       Topic: <select name="topic">
                            <?php  for($j=0; $j< sizeof($courseTopicsArr); $j++){ ?>

                        <?php if($topic== $courseTopicsArr[$j]->getTopic()){?>
                       <option selected="true">
                                 <?php        echo  $courseTopicsArr[$j]->getTopic();?></option>
                         <?php } else{ ?> <option> <?php echo  $courseTopicsArr[$j]->getTopic(); }?></option> <?php } ?>
                        </select>  
                        
                        <?php } ?>
                     
                    </div>
                    <div id="write_question">
                        <input type="text"  name="title" value="Write title of your question" size="54" onfocus="if(this.value=='Write title of your question')this.value=''"   /> <select name="time">
                            <option>Time in sec</option>
                            <option>10</option>
                            <option>20</option>
                            <option>30</option>
                        </select> <br></br><br></br>
                        <textarea name="question" rows="7" cols="57" value="Write your question here" onfocus="if(this.value=='Write your question here')this.value=''" >Write your question here</textarea>
                        </div>

                    <div id="choices">
                       <table border="0" cellpadding="10">

                            <tbody>
                                <tr>
                                    <td>Choice 1.       Correct Answer<input type="radio" name="correct_answer" value="1" /></td>
                                    <td>Choice 2.         Correct Answer<input type="radio" name="correct_answer" value="2" /></td>
                                </tr>
                                <tr>
                                    <td><input type="text" name="first" value="" size="30"  /></td>
                                    <td><input type="text" name="second" value="" size="30" /></td>
                                </tr>
                                <tr>
                                    <td>Choice 3.         Correct Answer<input type="radio" name="correct_answer" value="3" /></td>
                                    <td>Choice 4.         Correct Answer<input type="radio" name="correct_answer" value="4" /></td>
                                </tr>
                                <tr>
                                    <td><input type="text" name="third" value="" size="30" /></td>
                                    <td><input type="text" name="fourth" value="" size="30" /></td>
                                </tr>
                           <!-- </tbody> <div id="goldDiv"> Gold: <input type="text" name="gold" value="" size="10" /></div> -->
                           <tr>
                              <td align="middle"><input type="button" value="Reset" name="cancel" id="clear_button" onClick="this.form.reset()" /></td>
                              <td align="middle"><input type="submit" value="Submit" name="submit" id="submit_button" /></td>
                           </tr>
                        </table>
                        

                        </div>
                    
                    
          
	</form>
</div>

<?php include "../../layout/navright.php"; ?>
<?php include "../../layout/footer.php"; ?>
        </body>
</html>